# Contributor: Guy Godfroy <guy.godfroy@gugod.fr>
# Maintainer: Guy Godfroy <guy.godfroy@gugod.fr>
pkgname=reaction
pkgver=1.0.2
pkgrel=0
pkgdesc="Logs scanner for event triggering"
url="https://framagit.org/ppom/reaction"
license="AGPL-3.0-or-later"
arch="all"
makedepends="go gcc"
#install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc $pkgname-tools"
source="$pkgname-$pkgver.tar.gz::https://framagit.org/ppom/reaction/-/archive/v$pkgver/reaction-v$pkgver.tar.gz
	reaction.initd
	reaction.confd
	reaction.yml
	"
options="net !check" # check needs a postgres instance
builddir="$srcdir/$pkgname-v$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -o reaction .
	gcc ip46tables.d/ip46tables.c -o ip46tables
}

package() {
	install -Dm755 reaction "$pkgdir"/usr/bin/reaction
	install -Dm755 "$srcdir"/reaction.initd "$pkgdir"/etc/init.d/reaction
	install -Dm644 "$srcdir"/reaction.confd "$pkgdir"/etc/conf.d/reaction
	install -Dm644 "$srcdir"/reaction.yml "$pkgdir"/etc/reaction.yml
}

tools() {
	pkgdesc="Tools for use by Reaction"
	depends="iptables"
	install -Dm755 "$builddir"/ip46tables "$subpkgdir"/usr/bin/ip46tables
}

sha512sums="
46d33af33b377fef1d252747ec4f17f8d08efbc31c37ab362710225c0c4ffaf7ec377c6bf4ad62dfd6beea77a0b3ec24c98f14f9d6a1e548da49804a6e1bcc56  reaction-1.0.2.tar.gz
c2473cf3902ec42c045cd5f748ce27937fe1cb99e8e83e4920bd4ec10554c70339478d5756909d54889ed8eb0b8ba2bfe1307ba3be5e0e12a1c67895c82df606  reaction.initd
99e0fa2b72ad3e5793b1d99b7ca4a53ac4079afa1978f51897435b2660b97871f128b3038388f42e9fdc7c3d07a077aab1e9bd78c91b61b8c4b7b05dac1cce04  reaction.confd
abca80f725b14ec9d8f0c46c31658d16448ca5cc732b8c8d069c29cfb67b92abf571619a5152157dd8fc8bb44192912c698e46df9a1f18f851e20dd23123a58a  reaction.yml
"
